package cn.ycc1.boot3qrcode.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ycc
 * @date 2023/11/18
 */
@Configuration
public class SwaggerConfig {
    // http://127.0.0.1:8080/swagger-ui/index.html
    @Bean
    public OpenAPI restfulOpenApis() {
        return  new OpenAPI()
                .info(new Info()
                        .title("Spring Boot 3.0 Restful Open API")
                        .description("The Open API")
                        .version("1.0")
                        .license(new License().name("Apache")))
                .externalDocs(new ExternalDocumentation()
                        .description("The Open API"))
                .addSecurityItem(new SecurityRequirement().addList("Authorization"))
                .components(new Components().addSecuritySchemes("Authorization",
                        new SecurityScheme().name("Authorization").type(SecurityScheme.Type.HTTP).scheme("bearer").bearerFormat("")));
    }


}
